package com.masterclient.app.modules.income.contract;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil2;
import com.masterclient.app.modules.income.model.UnfreezeDetailsBean;
import com.masterclient.app.modules.income.model.WithdrawDetailsBean;

import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/09
*/
public class WithdrawDetailsPresenter extends WithdrawDetailsContract.Presenter{

    @Override
    public void getUnfreezeDetails(String id) {
        mRxManager.add(toSubscribe(RetrofitUtil2.getInstance().getUnfreezeDetails(id), (Consumer<CommonBaseResponse<UnfreezeDetailsBean>>) bean -> {
            if(bean.getCode() == 0){
                mView.showUnfreezeData(bean.getData());
            }else {
                mView.showDataFailed(bean.getMsg());
            }
        },new ThrowableConsumer() {
            @Override
            public void accept(Throwable o) throws Exception {
                mView.showDataFailed("网络异常，请重试");
                super.accept(o);
            }
        }));
    }

    @Override
    public void getWithdrawDetails(String id) {
        mRxManager.add(toSubscribe(RetrofitUtil2.getInstance().getWithdrawDetails(id), (Consumer<CommonBaseResponse<WithdrawDetailsBean>>) bean -> {
            if(bean.getCode() == 0){
                mView.showWithdrawData(bean.getData());
            }else {
                mView.showDataFailed(bean.getMsg());
            }
        },new ThrowableConsumer() {
            @Override
            public void accept(Throwable o) throws Exception {
                mView.showDataFailed("网络异常，请重试");
                super.accept(o);
            }
        }));
    }
}